<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>

    <button onclick="alert(666)">11</button>
    <button class="a" onclick="fn()">222</button>

    <script>

        // 行内事件   直接在标签上面定义
        // 直接绑定事件   oBtn.onclick = function(){}


        // 事件会发生覆盖



        var oBtn = document.querySelector('.a') ;

        oBtn.onclick = function() {
            console.log(2222);
        }

        function fn() {
            console.log(111);
        }

    </script>
    
</body>
</html>